package com.qianxun.module.datasource1.admin.rest;

import com.qianxun.module.datasource1.admin.service.SysDataModifyLockService;
import com.qianxun.module.datasource1.admin.service.SysMenuRoleRelationService;
import com.qianxun.module.datasource1.admin.util.SysMenuRoleUtil;
import com.qianxun.module.base.constant.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
* com.zch.admin.base.entity.SysRoleMenuRelation模型http接口处理
*
* @author: admin
* @date: 2019-11-13
* @version: 1.0.0
*/
@RestController
@RequestMapping("/admin/menuRoleRelation")
public class SysMenuRoleRelationRestController {
    @Resource
    private SysMenuRoleRelationService baseService;
    @Resource
    private SysDataModifyLockService sysDataModifyLockService;

    @RequestMapping(value = {"/setAuthority/{roleId}"})
    public Result setAuthority(@PathVariable(value = "roleId")Long roleId , @RequestParam(value = "menuIds") Long[] menuIds ){
        sysDataModifyLockService.checkLocked(SysMenuRoleUtil.dataLockKey(roleId));

        baseService.setAuthority(roleId ,menuIds);
        return Result.success();
    }
}
